package com.tgy.admin.controller;

import com.tgy.admin.Service.LoginService;
import com.tgy.ao.LoginAo;
import com.tgy.result.GraceJSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Scope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tianguiyin
 * @version 1.0
 * @date 2022/6/20 21:37
 */
@Validated
@Api(value = "登陆注册控制器", tags = {"登陆注册管理"})
@RestController
@RequestMapping("/admin")
// 异步调用注解
@Scope("prototype")
public class LoginController {

    @Resource
    private LoginService loginService;

    @ApiOperation("登录")
    @PostMapping("login")
    public String login(@Validated LoginAo ao){
        return loginService.login(ao);
    }

    @ApiOperation("注销")
    @PostMapping("logout")
    public GraceJSONResult logout(){
        return loginService.logout();
    }

}
